package demo.controller;

import com.jfinal.aop.Before;
import com.jfinal.aop.Clear;
import com.jfinal.core.Controller;
import com.jfinal.core.Path;
import com.jfinal.ext.interceptor.SessionInViewInterceptor;
import demo.controller.interceptor.LoginInterceptor;
import demo.controller.interceptor.LoginValidator;
import demo.domain.Student;

import javax.servlet.http.HttpSession;

@Path(value = "/student",viewPath = "/all/student")
@Clear(LoginInterceptor.class)
@Before(LoginValidator.class)
public class StudentLogin extends Controller {
    public void login() {
        String passwordReal="";
        String  a= get("username");
        String b=get("password");
        Student student= Student.dao.findById(a);
        if (student!=null){
             passwordReal= student.getStr("password");
        }

        boolean bb=false;
        if (passwordReal.equals(b)){
            bb=true;
        }


           setSessionAttr("username",a);
  renderJson(bb);
        //  System.out.println(a);
//        if (a!=null&&b!=null){
//            setSessionAttr("username",a);
//        }
//render("login.html");
    }
}
